package com.eclink.iot.tcp.virtualdevice.controller;

import com.eclink.iot.tcp.virtualdevice.VirtualDevice;
import com.eclink.iot.tcp.virtualdevice.VirtualDeviceManager;
import com.eclink.iot.tcp.virtualdevice.entity.Device;
import com.eclink.iot.tcp.virtualdevice.service.DeviceService;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("device")
public class DeviceController {

    @Resource
    private DeviceService deviceService;

    @GetMapping("list")
    public List<Device> list() {
        return deviceService.listAll();
    }

    @PostMapping("save")
    public ResponseEntity<Integer> save(@RequestBody Device device) {
        deviceService.save(device);
        return ResponseEntity.ok(1);
    }

}
